package mulMan;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import mulMan.domain.AudioFile;
import mulMan.domain.AudioFileModel;
import mulMan.domain.PlaylistModel;
import mulMan.gui.controller.AudioFileController;
import mulMan.gui.controller.AudioFilesController;
import mulMan.gui.controller.PlaylistController;
import mulMan.gui.view.AddFileView;
import mulMan.gui.view.AudioFileView;
import mulMan.gui.view.AudioFilesView;
import mulMan.gui.view.ModifyFileView;
import mulMan.gui.view.PlaylistView;
import mulMan.services.AudioFileServices;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		/*AudioFileModel audioFile = new AudioFileModel();
		//We create the View
		AudioFileView view = new AddFileView(audioFile);
		//We create the Controller
		new AudioFileController(audioFile, view);
		*/
		
		ApplicationContext context = new ClassPathXmlApplicationContext(
				"application-context.xml");
		AudioFileServices audioFileServices = (AudioFileServices) context.getBean("audioFileServices");
		
		List<AudioFileModel> audioFiles = new ArrayList<AudioFileModel>();
		List<AudioFile> list = new ArrayList<AudioFile>();
		
		try {
			list = audioFileServices.getAudioFiles();
			for (AudioFile iterator : list) {
				AudioFileModel audioFileDB = new AudioFileModel();
				audioFileDB.setAudioFile(iterator);
				audioFiles.add(audioFileDB);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		/*
		//We create the View
		AudioFilesView view2 = new AudioFilesView(audioFiles);
		//We create the Controller
		new AudioFilesController(audioFiles, view2);
		
		
		
		
		//We create the View
		AudioFileView view3 = new ModifyFileView(audioFiles.get(6));
		//We create the Controller
		new AudioFileController(audioFiles.get(6), view3);
		*/
		
		PlaylistModel playlist = new PlaylistModel();
		playlist.getPlaylist().setName("Tom's songs");
		playlist.setAudioFilesModels(audioFiles);
		
		PlaylistView view4 = new PlaylistView(playlist);
		
		new PlaylistController(playlist, view4);
	}
}
